var GFW = {

hosts:{
'aboluowang.com':true,
'www.bbc.co.uk':true,
'blogspot.com':true,
'bloomberg.com':true,
'chinadigitaltimes.net':true,
'cydia.pwndevteam.com':true,
'cydia.zodttd.com':true,
'dropbox.com':true,
'epochtimes.com':true,
'facebook.com':true,
'fbcdn.net':true,
'feedburner.com':true,
'fmnnow.com':true,
'goo.gl':true,
'google.com':true,
'www.google.cn':true,
'google.com.hk':true,
'googleusercontent.com':true,
'heqinglian.net':true,
'img.ly':true,
'ip6.me':true,
'letscorp.net':true,
'peacehall.com':true,
'posterous.com':true,
'rfi.fr':true,
'rfa.org':true,
't.co':true,
'twitlonger.com':true,
'twimg.com':true,
'twitpic.com':true,
'twitter.com':true,
'voanews.com':true,
'wikipedia.org':true,
'worldjournal.com':true,
'youporn.com':true,
'youtube.com':true,
'ytimg.com':true,
'wordpress.com':true,
'blogspot.jp':true,
'googlevideo.com':true,
'youtube-nocookie.com':true
}
};

var MY_HOSTS = [ <%= @hosts.html_safe %> ];
for(var i=0; i<MY_HOSTS.length; ++i){
	GFW.hosts[MY_HOSTS[i]] = true;
}
<% if @proxy %>
var MY_PROXY = 'PROXY <%= @proxy.html_safe %>';
<% else %>
var MY_PROXY = 'PROXY j10.jayproxy.org:3000; jp.jayproxy.net:6002; uk.jayproxy.net:6001';
<% end %>

var SAFE_DIRECT = 'DIRECT';
function FindProxyForURL(url, host) {
	var host_arr = host.split('.');
	if(host_arr[0]=='www'){
		host_arr.shift();
	}

	domain = host_arr.join('.');
	if(GFW.hosts[domain]){
		return MY_PROXY;
	}

	for(var unblock in GFW.hosts){
		if(host.indexOf(unblock)!== -1){
			return MY_PROXY;
		}
	}
	return SAFE_DIRECT;

}
